/*
 * Copyright (c) 2025 CAX Conversion Project
 */
package com.comac.ins.common.core.exception;

import com.comac.ins.common.core.enums.BizExceptionCodeEnum;
import lombok.Getter;

/**
 * 业务异常
 *
 * @author zhanghongyi
 * @date 2024/5/22 11:20
 * @description BizException
 */
@Getter
public class BizException extends RuntimeException {
    private static final long serialVersionUID = 8754113790998803664L;

    /**
     * 错误码
     */
    private final int code;

    public BizException(BizExceptionCodeEnum code, String msg) {
        super(msg);
        this.code = code.getCode();
    }

    public BizException(BizExceptionCodeEnum code, String msg, Throwable cause) {
        super(msg, cause);
        this.code = code.getCode();
    }

    public BizException(String msg) {
        super(msg);
        this.code = BizExceptionCodeEnum.BIZ_EXCEPTION.getCode();
    }

    public BizException(String msg, Throwable cause) {
        super(msg, cause);
        this.code = BizExceptionCodeEnum.BIZ_EXCEPTION.getCode();
    }
}
